/**
 * 省市区选择组件
 * onSureClick 
 * onCacnelClick
 */
Component({
  behaviors: [],//复用代码段

  properties:{
    proValue: {//默认
      type:String,
      value: '京'
    },  
    isShow: {//是否显示
      type: Boolean,
      value:false
      }  
  },
  data: {
    proCodeList: ["京", "沪", "浙", "苏", "粤", "鲁", "晋", "冀",
      "豫", "川", "渝", "辽", "吉", "黑", "皖", "鄂",
      "津", "贵", "云", "桂", "琼", "青", "新", "藏",
      "蒙", "宁", "甘", "陕", "闽", "赣", "湘"],
    proActive: ''
  },
  lifetimes: {
    ready() {
      this.onValue();
    }
  },
  methods: {
    onValue() {
      for (var i = 0; i < this.data.proCodeList.length; i++) {
        let item = this.data.proCodeList[i];
        if (item == this.properties.proValue) {
          this.setData({
            proActive: i
          })
        }
      }
    },
    //确定
    onSureClick(e){
      let index = e.currentTarget.dataset.idx;
      var proValue = this.data.proCodeList[index];
      this.setData({
        proValue: this.data.proCodeList[index],
        proActive: index
      })
      var selectValue={
        proValue: proValue
      }
      this.triggerEvent('eventSureClick', selectValue);
    },
        //取消
    onCacnelClick(){
      this.setData({
        isShow: false
      })
      this.triggerEvent('onCacnelClick',{});
    }
  }
});